package cn.matrix42.potoo.format.markdown.element.chart.table;

import cn.matrix42.potoo.lang.StringUtils;

public class TableHeader extends TableRow {

    public TableHeader(int column) {
        super(column);
    }

    @Override
    public String toMarkdownString() {
        StringBuilder builder = new StringBuilder();
        builder.append(super.toMarkdownString());
        builder.append("| ");
        for (int i = 0; i < rowContent.size(); i++) {
            if (i == 0) {
                builder.append(":");
                builder.append(StringUtils.repeat("-", rowContent.size())).append(" |");
            } else {
                builder.append(" ").append(StringUtils.repeat("-", rowContent.size())).append(" |");
            }
        }
        builder.append(context.getConfig().getEof());
        return builder.toString();
    }

}
